﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SelfService.DataAccess.Migrations
{
    public partial class 新增中间表处方项目清单 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "OrderTime",
                table: "SysPrescriptions");

            migrationBuilder.CreateTable(
                name: "SysPrescriptionProjects",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    PrescriptionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    ProjectId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysPrescriptionProjects", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysPrescriptionProjects_SysMedicalProjects_ProjectId",
                        column: x => x.ProjectId,
                        principalTable: "SysMedicalProjects",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysPrescriptionProjects_SysPrescriptions_PrescriptionId",
                        column: x => x.PrescriptionId,
                        principalTable: "SysPrescriptions",
                        principalColumn: "ID");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_SysPrescriptionProjects_PrescriptionId",
                table: "SysPrescriptionProjects",
                column: "PrescriptionId");

            migrationBuilder.CreateIndex(
                name: "IX_SysPrescriptionProjects_ProjectId",
                table: "SysPrescriptionProjects",
                column: "ProjectId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysPrescriptionProjects");

            migrationBuilder.AddColumn<string>(
                name: "OrderTime",
                table: "SysPrescriptions",
                type: "varchar(64)",
                maxLength: 64,
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");
        }
    }
}
